package com.zhu.transaction.mapper.imp;

import com.zhu.transaction.mapper.CategoryMapper;
import com.zhu.transaction.pojo.Category;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Zhu
 * @createtime 2021/1/21-9:10
 */

@Repository
public class CategoryMapperImp implements CategoryMapper {

    @Autowired
    SqlSession sqlSession;

    @Override
    public int addCategory(Category category) {
        return sqlSession.getMapper(CategoryMapper.class).addCategory(category);
    }

    @Override
    public Category queryFirstCategory(String categoryName) {
        return sqlSession.getMapper(CategoryMapper.class).queryFirstCategory(categoryName);
    }

    @Override
    public Category queryCategoryById(String id) {
        return sqlSession.getMapper(CategoryMapper.class).queryCategoryById(id);
    }

    @Override
    public List<Category> queryCategoryByParent(String parent) {
        return sqlSession.getMapper(CategoryMapper.class).queryCategoryByParent(parent);
    }

    @Override
    public int deleteCategoryById(String id) {
        return sqlSession.getMapper(CategoryMapper.class).deleteCategoryById(id);
    }

    @Override
    public int updateCategory(String id, String categoryName) {
        return sqlSession.getMapper(CategoryMapper.class).updateCategory(id, categoryName);
    }

}
